<?php

/**
 * @category   mediad2
 * @package    Mediad2_Service
 */
class Mediad2_Service_Admin_DictType extends Mediad2_Service_Abstract
{
	/**
	 * 初始化
	 */
	public function init()
	{
		$this->setMapper('Mediad2_Mapper_DictType');
		$this->setModel('Mediad2_Model_DictType');
	}
	
	/**
	 * 根据字典类型代码，返回字典类型的其他信息
	 *
	 * @param string $code
	 * @return Mediad_Model_GloDictType
	 */
	public function findDictTypeByCode($code)
	{
		$parms = array('code' => $code,);
	
		$mapper = $this->getMapper();
		$dao = $mapper->getDao();
		$adapter = $dao ->getAdapter();
		$selector = $dao->select();
		foreach ($parms as $key => $value) {
			$selector->where($adapter->quoteInto("$key=?",$value));
		}
	
		$result = $dao->fetchRow($selector);
	
		$model = $this->getModel();
		if (!null == $result) {
			$model->setOptions($result->toArray());
		}
		return $model;
	}
	
}